package com.jtx.miaoah2.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author 季台星
 * @Date 2023 07 23 19 46
 */
@Configuration
public class ThreadPoolConfig {
    /**
     * 预下单线程池
     * 抛弃拒绝策略
     * @return
     */
    @Bean
    public ThreadPoolExecutor snappedThreadPool(){
        return new ThreadPoolExecutor(5,
                10,
                2L,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1000),new ThreadPoolExecutor.DiscardPolicy());
    }
}
